<%--
  Created by IntelliJ IDEA.
  User: 杨威
  Date: 2021/9/23
  Time: 17:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>发送json数据</title>
    <script src="js/jquery-1.12.4.js"></script>
</head>
<body>
用户名：<input type="text" id="username" /><br/>
密码：<input type="password" id="password"/><br/>
<button onclick="logins()">登录</button>
<script type="text/javascript">

    function logins(){
        var user={"username":$("#username").val(),"password":$("#password").val()}
        var s = JSON.stringify(user);
        $.ajax({
            url:"login2",
            type:"post",
            data:s,
            contentType:"application/json;charset=utf-8",
            success:function (msg) {
                alert(msg)
            }
        })
    }

</script>
</body>
</html>
